package com.itboye.jmsfhz.data.presenter;

import java.util.List;
import java.util.Observer;

import android.util.Log;

import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.object.BasePresenter;
import com.itboye.core.object.ResultEntity;
import com.itboye.jmsfhz.app.ui.main.MainPresenter;
import com.itboye.jmsfhz.data.interfaces.IPrisenter;
import com.itboye.jmsfhz.data.repository.PrisenterRepository;
import com.lfh.commentdemo.bean.AppModelNewsBean;

public class Personnelpresenter extends BasePresenter implements
		IPrisenter<AppModelNewsBean> {

	public static final String PictureSuccessEvent = MainPresenter.class
			.getName() + "_Picture_success";
	public static final String PictureFailEvent = MainPresenter.class.getName()
			+ "_Picture_failure";

	public static final String GonggaoSuccessEvent = MainPresenter.class
			.getName() + "_Gonggao_success";
	public static final String GonggaoFailEvent = MainPresenter.class.getName()
			+ "_Gonggao_failure";

	public static final String HeZuoSuccessEvent = MainPresenter.class
			.getName() + "_HeZuo_success";
	public static final String HeZuoFailEvent = MainPresenter.class.getName()
			+ "_HeZuo_failure";

	public static final String NewsSuccessEvent = MainPresenter.class.getName()
			+ "_News_success";
	public static final String NewsFailEvent = MainPresenter.class.getName()
			+ "_News_failure";

	public static final String ProjectSuccessEvent = MainPresenter.class
			.getName() + "_Project_success";
	public static final String ProjectFailEvent = MainPresenter.class.getName()
			+ "_Project_failure";

	public Personnelpresenter(Observer observer) {
		super(observer);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void add(AppModelNewsBean model) {
		// TODO Auto-generated method stub

		IPrisenter<AppModelNewsBean> banner = new PrisenterRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "lunbo success");
						result.setEventTag(Tag_Success);
						result.setEventType(PictureSuccessEvent);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "lunbo fail");
						result.setEventTag(Tag_Error);
						result.setEventType(PictureFailEvent);
						setChanged();
						notifyObservers(result);
					}
				});
		banner.add(model);
	}

	@Override
	public void delete(AppModelNewsBean model) {
		// TODO Auto-generated method stub
		IPrisenter<AppModelNewsBean> banner = new PrisenterRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "lunbo success");
						result.setEventTag(Tag_Success);
						result.setEventType(GonggaoSuccessEvent);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "lunbo fail");
						result.setEventTag(Tag_Error);
						result.setEventType(GonggaoFailEvent);
						setChanged();
						notifyObservers(result);
					}
				});
		banner.update(model);
	}

	@Override
	public void update(AppModelNewsBean model) {
		// TODO Auto-generated method stub
		IPrisenter<AppModelNewsBean> banner = new PrisenterRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "lunbo success");
						result.setEventTag(Tag_Success);
						result.setEventType(NewsSuccessEvent);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "lunbo fail");
						result.setEventTag(Tag_Error);
						result.setEventType(NewsFailEvent);
						setChanged();
						notifyObservers(result);
					}
				});
		banner.update(model);
	}

	@Override
	public void getInfo(AppModelNewsBean model) {
		// TODO Auto-generated method stub
		IPrisenter<AppModelNewsBean> banner = new PrisenterRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "lunbo success");
						result.setEventTag(Tag_Success);
						result.setEventType(HeZuoSuccessEvent);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "lunbo fail");
						result.setEventTag(Tag_Error);
						result.setEventType(HeZuoFailEvent);
						setChanged();
						notifyObservers(result);
					}
				});
		banner.getInfo(model);
	}

	@Override
	public List<AppModelNewsBean> query(AppModelNewsBean model) {
		// TODO Auto-generated method stub
		return null;
	}

}
